﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ChangeProblem.Logic
{
    public class ChangeProblems
    {

        public decimal Change(decimal payMents, decimal priceCost)
        {
            decimal theRestMenoy = payMents - priceCost;
            return theRestMenoy;
        }
        public int[] GetNumbers(decimal change, decimal[] denomination, int[] denominationNumbers)
        {
            for (int i = 0; i < denomination.Length; i++)
            {
                denominationNumbers[i] = (int)(change / denomination[i]);
                change = change - denomination[i] * denominationNumbers[i];
            }
            return denominationNumbers;
        }
    }
    public class ChangeProblems2
    {
        public decimal Change(decimal payMents, decimal priceCost)
        {
            decimal theRestMenoy = payMents - priceCost;
            return theRestMenoy;
        }
        public int[] GetNumbers(decimal change, decimal[] denomination, int[] denominationNumbers, int[] denominationNumber)
        {
            for (int i = 0; i < denomination.Length; i++)
            {

                denominationNumber[i] = (int)(change / denomination[i]);
                if (denominationNumbers[i] < denominationNumber[i])
                {
                    denominationNumber[i] = denominationNumbers[i];
                }
                change = change - denomination[i] * denominationNumber[i];
            }
            return denominationNumber;
        }
    }
}
